package com.yf.pagination;

import com.yf.util.PageUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

import java.io.Serializable;

/**
 * 分页参数
 *
 * @author wangbiao
 * @date 2016-08-18 14：29
 */
@ApiModel(value = "分页参数")
public class PageParams implements Serializable {

    private static final long serialVersionUID = 1141847591240587345L;


    /**
     * 当前页
     */
    @ApiModelProperty(value = "当前页", required = true, name = "currentPage")
    private Integer currentPage = PageUtils.DEFAULT_CURRENT_PAGE;

    /**
     * 每页记录数
     */
    @ApiModelProperty(value = "每页记录数", required = true, name = "pageSize")
    private Integer pageSize = PageUtils.DEFAULT_PAGE_SIZE;


    public PageParams() {
        super();
    }

    public PageParams(Integer currentPage, Integer pageSize) {
        super();
        this.setCurrentPage(currentPage);
        this.setPageSize(pageSize);
    }

    public Integer getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(Integer currentPage) {
        this.currentPage = PageUtils.getValidPageParams(currentPage, PageUtils.PageParamsType.CURRENT_PAGE);
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = PageUtils.getValidPageParams(pageSize, PageUtils.PageParamsType.PAGE_SIZE);
    }

    @Override
    public String toString() {
        return ReflectionToStringBuilder.toString(this);
    }

}
